<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>

    <link rel='stylesheet' href='/stylesheets/bootstrap.css' />
    <link rel='stylesheet' href='/stylesheets/signin.css' />
    <link rel='stylesheet' href='/stylesheets/dashboard.css' />
    <link rel='stylesheet' href='/stylesheets/fileinput.css' />

    <script src="/javascripts/jquery-1.9.1.min.js"></script>
    <script src="/javascripts/bootstrap.js"></script>
    <script src="/javascripts/fileinput.js"></script>


  </head>
  <body>
  <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">欢迎使用Jimmy网盘系统</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">Project name</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#">Dashboard</a></li>
          <li><a href="#">Settings</a></li>
          <li><a href="#">Profile</a></li>
          <li><a href="#">Help</a></li>
          <li><a id="username" href="#"><%= username %></a></li>
        </ul>
        <form class="navbar-form navbar-right">
          <input type="text" class="form-control" placeholder="Search...">
        </form>
      </div>

    </div>
  </nav>

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar">
        <ul class="nav nav-sidebar">
          <li class="active"><a href="#">LoadAll <span class="sr-only">(current)</span></a></li>
          <li><a href="#">文档</a></li>
          <li><a href="#">图片</a></li>
          <li><a href="#">视频</a></li>
          <li><a href="#">音乐</a></li>
          <li><a href="#">种子</a></li>
          <li><a href="#">分享</a></li>
          <li><a href="#">回收站</a></li>
          <li> <button  class="btn btn-sm btn-primary" type="button" data-toggle='modal' data-target='.upload'>上传文件</button></li>
        </ul>

        </ul>
      </div>s
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ">
        <h1 class="page-header">Dashboard</h1>
        <div class="row placeholders">
          <div class="col-xs-6 col-sm-3 placeholder">

            <h4>Label</h4>
            <span class="text-muted">Something else</span>
          </div>
          <div class="col-xs-6 col-sm-3 placeholder">

            <h4>Label</h4>
            <span class="text-muted">Something else</span>
          </div>
          <div class="col-xs-6 col-sm-3 placeholder">

            <h4>Label</h4>
            <span class="text-muted">Something else</span>
          </div>
          <div class="col-xs-6 col-sm-3 placeholder">

            <h4>Label</h4>
            <span class="text-muted">Something else</span>
          </div>
        </div>

        <h2 class="sub-header">详细信息</h2>
        <div class="table-responsive ">
          <table class="table table-striped table-bordered ">
            <thead>
            <tr>
              <th>序号</th>
              <th>文件名称</th>
              <th>文件类型</th>
              <th>大小</th>
              <th>上传时间</th>
              <th>下载次数</th>
              <th>勾选框</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr>
              <td>1</td>
              <td>哈哈</td>
              <td>.png</td>
              <td>12M</td>
              <td>2017-08-20 07:27:30</td>
              <td>1次</td>
              <td> <input value="checked" type="checkbox"></td>
              <td> <input value="打开" type="button" class="btn btn-primary btn-xs">
                <input value="下载" type="button" class="btn btn-info btn-xs">
                <input value="删除" type="button" class="btn btn-danger btn-xs">

              </td>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>


  <div class="modal fade upload" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">上传文件</h4>
        </div>
        <div class="modal-body">

          <form class="myForm">
            <div class='form-group'>
              <div class="col-md-14">
                <div class="fileinput fileinput-new" data-provides="fileinput" id="uploadImageDiv">
                  <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                    <img src="" alt="请选择上传文件" />
                  </div>
                  <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 300px;"></div>
                  <form id="uploadForm" enctype="multipart/form-data">
                        <span class="btn default btn-file">
                          <span class="fileinput-new">选择文件</span>
                          <span class="fileinput-exists">更改</span>
                          <input id="upfile" type="file" name="uploadImage"/></span>
                    <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">移除</a>
                    <span>请选择1M大小以内的文件</span>
                      <div class='form-group'>
                          <label>上传名称：</label>
                          <input id="upfilename" type="text" name="username" class='form-control'>
                      </div>
                      <input type="button" name="" value="上传" class='btn btn-sm btn-info' onclick="up()">
                  </form>
                </div>
                <div id="titleImageError" style="color: #a94442"></div>
              </div>
            </div>

          </form>
        </div>
        <div class="modal-footer">

        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
  <script type="text/javascript">
      function up(){
          var file=$("#upfile")[0];
          alert(file.files[0].name);
          var formData = new FormData();
          var username = $("#username").text();

          formData.append("avatar", file.files[0]);
          formData.append("username", username);

         $.ajax({
              type: 'post',
              url: '/upfile',
              data: formData,
              processData: false,
              contentType: false,
              success: function (data) {

              },
              error: function (err) {
                  console.log(err.message);
              }
          })
      }
  </script>

  </body>
</html>
